https://github.com/golang/go/wiki/Ubuntu
$ go get github.com/SkycoinProject/hardware-wallet-goThis project uses dep dependancy manager.
Don't modify anything under vendor/ directory without using dep commands.
Download dependencies using command:
$ make dep$ go run cmd/cli/cli.goSee also CLI README for information about the Command Line Interface.
Code added in this repository should comply to development guidelines documented in Skycoin wiki.
The project has two branches: master and develop.
developis the default branch and will always have the latest code.masterwill always be equal to the current stable release on the website, and should correspond with the latest release tag.
This go client library follows the versioning rules for SkyWallet client libraries .
Library test suite can be run by running the following command
make test
If a physical SkyWallet device is connected then the test suite will exchange test messages with it. Likewise, the emulator will reply to test messages if executed in advance as follows.
git clone https://github.com/SkycoinProject/hardware-wallet /some/path/to/hardware-wallet
make clean -C /some/path/to/hardware-wallet && make -C /some/path/to/hardware-wallet run-emulator
If neither the emulator nor a physical device are connected then tests will be skipped silently.
- If the
masterbranch has commits that are not indevelop(e.g. due to a hotfix applied tomaster), mergemasterintodevelop(and fix any build or test failures) - Switch to a new release branch named
release-X.Y.Zfor preparing the release. - Run
make buildto make sure that the code base is up to date - Update
CHANGELOG.md: move the "unreleased" changes to the version and add the date. - Follow the steps in pre-release testing
- Make a PR merging the release branch into
master - Review the PR and merge it
- Tag the
masterbranch with the version number. Version tags start withv, e.g.v0.20.0. Sign the tag. If you have your GPG key in github, creating a release on the Github website will automatically tag the release. It can be tagged from the command line withgit tag -as v0.20.0 $COMMIT_ID, but Github will not recognize it as a "release". - Tag the changeset of the
protobsubmodule checkout with the same version number as above. - Release builds are created and uploaded by travis. To do it manually, checkout the master branch and follow the create release builds instructions.
- Checkout
developbranch and bumptiny-firmware/VERSIONandtiny-firmware/bootloader/VERSIONto nextdevversion number.
Pre-release testing procedure requires skycoin-cli of version strictly greater than 0.26.0. Please install it if not available in your system. Some operations in the process require running a Skycoin node. Also clone Skywallet firmware repository in advance.
The instructions that follow are meant to be followed for Skywallet devices flashed without memory protection. If your device memory is protected then some values might be different e.g. firmwareFeatures.
During the process beware of the fact that running an Skycoin node in the background can block the Skywallet from running.
Some values need to be known during the process. They are represented by the following variables:
WALLET1,WALLET2, ... names of wallets created byskycoin_cliADDRESS1,ADDRESS2, ... Skycoin addressesTXN1_RAW,TXN2_RAW, ... transactions data encoded in hex dump formatTXN1_JSON,TXN2_JSON, ... transactions data encoded in JSON format, if numeric index value matches the one of another variable withRAWprefix then both refer to the same transactionTXN1_ID,TXN2_ID, ... Hash ID of transactions after broadcasting to the P2P networkAMOUNTrepresents an arbitrary number of coinsID1,ID2,ID3, ... unique ID values , usually strings identifying hardware or software artifactsAUTHTOKENis a CSRF token for the Skycoin REST API
Perform these actions before releasing:
Note : In all cases skycoin-cli would be equivalent to go run cmd/cli/cli.go if current working directory set to $GOPATH/src/github.com/SkycoinProject/skycoin.
- Open a terminal window and run Skywallet emulator. Wait for emulator UI to display.
- From a separate trminal window run the test suite as follows
npm run test- Close emulator and plug Skywallet device. Run the same command another time.
- Create new wallet e.g. with
skycoin-cli(or reuse existing wallet for testing purposes)
skycoin-cli walletCreate -f $WALLET1.wlt -l $WALLET1- From command output take note of the seed
SEED1and addressADDRESS1 - List wallet addresses and confirm that
ADDRESS1is the only value in the list.
skycoin-cli listAddresses $WALLET1.wlt- Transfer funds to
ADDRESS1in new wallet in two transactions - Check balance
skycoin-cli addressBalance $ADDRESS1- List address for
WALLET1and check thathead_outputsin response includes to outputs withaddressset toADDRESS1
skycoin-cli walletOutputs $WALLET1.wlt
- Get device features and check that:
vendoris set toSkycoin FoundationdeviceIdis a string of 24 chars, which we'll refer to asID1- write down the value of
bootloaderHashi.e.ID2 modelis set to'1'fwMajoris set to expected firmware major version numberfwMinoris set to expected firmware minor version numberfwPatchis set to expected firmware patch version numberfirmwareFeaturesis set to0
- Ensure device is seedless by wiping it. Check that device ends up in home screen with
NEEDS SEED!message at the top. - Recover seed
SEED1in Skywallet device (dry-run=false). - Get device features and check that:
vendoris set toSkycoin FoundationdeviceIdis set toID1pinProtectionis seto tofalsepassphraseProtectionis set tofalselabelis set toID1initializedis set totruebootloaderHashis set toID2passphraseCachedis set tofalseneedsBackupis set tofalsemodelis set to'1'fwMajoris set to expected firmware major version numberfwMinoris set to expected firmware minor version numberfwPatchis set to expected firmware patch version numberfirmwareFeaturesis set to0
- Set device label to a new value , say
ID3. SpecifyusePassphrase=false. - Get device features and check that:
labelis set toID3- all other values did not change with respect to previous step, especially
deviceId - as a result device label is displayed on top of Skycoin logo in device home screen
- Ensure you know at least two addresses for test wallet, if not, generate some. Choose the second and third in order, hereinafter referred to as
ADDRESS2,ADDRESS3respectively - Check that address sequence generated by SkyWallet matches the values generated by
skycoin-cli
skycoin-cli walletAddAddresses -f $WALLET1.wlt -n 5- Check once again with desktop wallet
- Create new transaction from
ADDRESS1toADDRESS2in test wallet (sayTXN_RAW1) for an spendable amount higher than individual output's coins
export TXN1_RAW="$(skycoin-cli createRawTransaction -a $ADDRESS1 -f $WALLET1.wlt $ADDRESS2 $AMOUNT)"
echo $TXN1_RAW- Display transaction details and confirm that it contains at least two inputs
export TXN1_JSON=$(skycoin-cli decodeRawTransaction $TXN1_RAW)
echo $TXN1_JSON- Sign transaction with Skywallet by putting together a message using values resulting from previous step as follows.
- For each hash in transaction
inputsarray and in same order there should be- an instance of
--inputHashcommand line argument set to the very same hash - an instance of
--inputIndexset to0.
- an instance of
- For each source item in transaction
outputsarray and in the same order there should be command-line arguments set as follows:--outputAddress: source item'sdst--coin: source item'scoins * 1000000--hour: source item'shours--addressIndex: set to0if source itemaddressequalsADDRESS1or to1otherwise
- For each hash in transaction
- Check that
signaturesarray returned by hardware wallet includes entries for each and every transaction input - Check signatures were signed by corresponding addresses
- Create transaction
TXN2_JSONby replacingTXN1_JSONsignatures with the array returned by SkyWallet - Use
TXN2_JSONto obtain encoded transactionTXN2_RAW
export $TXN2_RAW=$( echo "$TXN2_JSON" | skycoin-cli encodeJsonTransaction --fix - | grep '"rawtx"' | cut -d '"' -f4)
echo $TXN2_RAW- Broadcast transaction. Refer to its id as
TXN2_ID
export TXN2_ID=$(skycoin-cli broadcastTransaction $TXN2_RAW)- After a a reasonable time check that balance changed.
skycoin-cli walletBalance $WALLET1.wlt- Create a second wallet i.e.
WALLET2
skycoin-cli walletCreate -f $WALLET2.wlt -l $WALLET2- From command output take note of the seed
SEED2and addressADDRESS4 - List
WALLET2addresses and confirm thatADDRESS4is the only value in the list.
skycoin-cli lisAddresses $WALLET2.wlt- Transfer funds to
WALLET2(if not already done) and check balance
skycoin-cli addressBalance $ADDRESS4- Request CSRF token (i.e.
AUTHTOKEN) using Skycoin REST API.
curl http://127.0.0.1:6420/api/v1/csrf- Use Skycoin REST API to create one transaction grabbing all funds from
ADDRESS1(i.e. first address inWALLET1previously recovered in Skywallet device),ADDRESS2(i.e. second address inWALLET1previously recovered in Skywallet device) andADDRESS4(i.e. first address inWALLET2) so as to transfer to the third address ofWALLET1(i.e.ADDRESS3). Change should be sent back toADDRESS1. In server response transaction JSON object (a.k.aTNX3_JSON) would be the object atdata.transactionJSON path. If Skycoin node was started with default parameters this can be achieved as follows:
curl -X POST http://127.0.0.1:6420/api/v2/transaction -H 'content-type: application/json' -H "X-CSRF-Token: $AUTHTOKEN" -d "{
\"hours_selection\": {
\"type\": \"auto\",
\"mode\": \"share\",
\"share_factor\": \"0.5\"
},
\"addresses\": [\"$ADDRESS1\", \"$ADDRESS2\", \"$ADDRESS4\"],
\"change_address\": \"$ADDRESS1\",
\"to\": [{
\"address\": \"$ADDRESS3\",
\"coins\": \"$AMOUNT\"
}],
\"ignore_unconfirmed\": false
}"- Sign transaction represented by
TXN3_JSONfor inputs owned by Skywallet (i.e.WALLET1)- For each object in transaction
inputsarray there should be:- an instance of
--inputHashcommand line argument set to the value bound to object'suxidkey - an instance of
--inputIndexset as follows- empty string if input
addressisADDRESS4 0if inputaddressisADDRESS11if inputaddressisADDRESS2
- empty string if input
- an instance of
- For each source item in transaction
outputsarray there should be command-line arguments set as follows:--outputAddress: source item'saddress--coin: source item'scoins * 1000000--hour: source item'shours--addressIndexset to 2 (since destination address isADDRESS3)
- For each object in transaction
- Check that signatures array includes one entry for every input except the one associated to
ADDRESS4, which should be an empty string - Recover seed
SEED2in Skywallet device (dry-run=false). - Sign transaction represented by
TXN3_JSONfor inputs owned by Skywallet (i.e.WALLET2)- For each hash in transaction
inputsarray and in same order there should be:- an instance of
--inputHashcommand line argument set to the value bound to object'suxidkey - an instance of
--inputIndexset to a value as follows- not set if input
addressisADDRESS1 - not set if input
addressisADDRESS2 0if inputaddressisADDRESS4
- not set if input
- an instance of
- For each source item in transaction
outputsarray and in the same order there should be command-line arguments set as follows:--outputAddress: source item'sdst--coin: source item'scoins * 1000000--hour: source item'shours--addressIndexempty (since destination addressADDRESS3not owned by this wallet)
- For each hash in transaction
- Create a new transaction JSON object (a.k.a
TXN4_JSON) fromTXN3_JSONand the previous signatures like thistypesame as inTXN3_JSONinner_hashshould be an empty stringsigsreturned by SkyWallet in same order as corresponding inputinputsis an array of strings. For each item inTXN3_JSONinputsinclude the value of itsuxidfield inTXN4_JSONinputsarray. Respect original order.outputsis an array of objects constructed out ofTXN3_JSONoutputsitems, in te same order, as followsdst: source item'saddresscoins: source item'scoins * 1000000hours: source item'shoursas integer
- Use
TXN4_JSONto obtain encoded transactionTXN4_RAW
export $TXN4_RAW=$( echo "$TXN4_JSON" | skycoin-cli encodeJsonTransaction --fix - | grep '"rawtx"' | cut -d '"' -f4)
echo $TXN4_RAW- Broadcast transaction. Refer to its id as
TXN4_ID
export TXN4_ID=$(skycoin-cli broadcastTransaction $TXN4_RAW)- After a a reasonable time check that wallets balance changed.
skycoin-cli walletBalance $WALLET1.wlt
skycoin-cli walletBalance $WALLET2.wltMore information in the wiki
