NEO Exchange offline wallet develop the signature block chain [JAVA]

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_18537055/article/details/98681120

Preface:

        In March 2019 my overwhelming "block chain" network storm, just one ear into another on help to be lost ... In mid-March, when a job so I decided to reach him, after all, Ma uncle said: only in the future of artificial intelligence (AI) and the block chain ...... I received the first command is to do NEO (small ants currency) cold wallet, but I even saw the official website no signature, not to say cold wallet, it's all online information is not received by some things much use of ... ah good side, but the entry of the first tasks will escape it? Stop and take your time?

        In the development of a currency, you must be familiar with his trading process, so you will not detour ... because I walked too much

Step One: Download kefuduan create one of their own wallet

        Download: https://github.com/neo-project/neo-gui/releases I downloaded: neo-gui-windows.zip (create a wallet that will not say chant, all Chinese, and if it does not Give it up, this step to create a wallet called a)

        Before you create a wallet wallet kefuduan it becomes the reference test network: https://docs.neo.org/zh-cn/network/testnet.html

Step 2: Request test coins

        Application Address: https://neo.org/testcoin/apply  attention to the rearmost sure to fill public address after the first step to create a wallet in the corresponding public key, so you have the public key, or you took the test not take money (and I'm much suffering in), you go to apply for a good look at those documents he needs it, wait until you receive the message test B.

Step 3: Create multiple signatures and transfers based on the mail address

        The first step has been said that there are links multiple signing the transfer, you direct your first step to transit. Go down to the newly created wallet you turn, you find that these steps are not the private key signature does not appear, it is a direct signature of success.
        Now re-create a new wallet B, get rid of it generated address, create a contract directly address. Put the money inside to A, as shown in the next to get
this step is very important to keep a copy of it, analyzing the data back, understand other people's signature dome are of great help.

Step four: Signature and Broadcasting

        In the first step of signing wallet (address must be in the contract, otherwise you transfer your wallet and did not address the relationship is not signed) as shown below:

You see the transaction will be successful. But this is the customer service side of the little off-line signature relationship with us to achieve ah, rest assured quicken workers work .....

Step five: Download the god dome

        I also see this address when: https://www.jianshu.com/p/286c3cca3048 (of which there are many things)
        found in the community interested in the inside: Dr. Guil in NEO DevCon introduction Neow3j Java library
        to download project: https://github.com/neow3j/neow3j
        inside the official api basically achieved, but also did not realize was Kazakhstan

Step Six: Analyze

        This step is very important, and to find the dome of io.neow3j.examples.ransactions.CreateRawTransactionMultiSig.java, this is the signature of the things that I transfer the signature of the customer service side of the java content .... this is a multi-signature (this is not to do more to explain the Baidu ha) now look at what is the meaning of these data:

WIF is private purse, wallet can be found by, you can get in io.neow3j.examples.utils.LoadWallet
ecKeyPair3 is superfluous It can kill, if you sign only once, ecKeyPair2 can also kill.
Assets acquired id: neow3j.getAccountState

Now talk about: What is the address output? I used to resolve customer service side of the transaction: Address: https://sdk.nel.group/# resolve that record the signature of money (I say that a good save) in the hex, put the link in the transaction resolved, I began thought it was private, I joined the signature ok, broadcast on the error, the transaction validation error substantially more than the mean. In this ink for a long time ...... then again to see the official document neo hair is UTXO (Baidu understand what it means), so I checked the address information: https: //neoscan-testnet.io/api/ test_net / v1 / get_balance / address plus signature hairstyle unspent.txid, estimated that he, and the next test, the success of the broadcast, currency trading success. And I added to my offline signature project (implemented once signature):

End: Finish line Signature

@RequestMapping("/neo/offline")
public class NeoController {
    @Autowired
	public NeoInfo NeoInfo;
    
    @ApiOperation(value = "NEO离线签名", notes = "NEO离线签名")
	@RequestMapping(value="/sign", method = RequestMethod.GET)
    public String sign(NeoParam param) {
		ECKeyPair ecKeyPair = ECKeyPair.create(WIF.getPrivateKeyFromWIF(NeoInfo.getWif()));
		
		String multiSigAddress = Keys.getMultiSigAddress(1,ecKeyPair.getPublicKey());
		
		RawVerificationScript verificationScript = Keys.getVerificationScriptFromPublicKey(1,ecKeyPair.getPublicKey());
		
		RawTransaction rawTx = RawTransaction.createContractTransaction(
                null,
                null,
                Arrays.asList(
                        new RawTransactionInput(param.getUnspentTxid(), 0)
                ),
                Arrays.asList(
                        new RawTransactionOutput(0, param.getOutputAssetId(), param.getOutValue(), param.getInputAddress()),
                        new RawTransactionOutput(1, param.getOutputAssetId(), param.getChangeValue(), multiSigAddress)
                )
        );
		// 序列化基本原始事务
        // 重要:没有脚本!
        byte[] rawTxUnsignedArray = rawTx.toArray();

        // 在三种可能的签名中添加两个签名——这里的顺序很重要!
        List<RawInvocationScript> rawInvocationScriptList = new ArrayList<>();
        rawInvocationScriptList.add(new RawInvocationScript(Sign.signMessage(rawTxUnsignedArray, ecKeyPair)));
        rawTx.addScript(rawInvocationScriptList, verificationScript);
        byte[] rawTxSignedArray = rawTx.toArray();
		return Numeric.toHexStringNoPrefix(rawTxSignedArray);
    }
}

First contact with digital currency, many do not know the terminology, take a lot of detours, subsequent to continue its efforts to start other coins .....
have developed purse plus group: 340 697 945, the answer back to the wallet share with everyone Learn.

Guess you like

Origin blog.csdn.net/qq_18537055/article/details/98681120