Skip to content

adding function for HD wallet testing #683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/transaction/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ var (
nodeOwnerAccountAddress string
nodeAddress string
lockedBalance int64
poowMessageByte []byte
signatureByte []byte
nodePubKey []byte
Comment on lines +41 to +43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this variable will use?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused. will delete later

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

proofOfOwnershipHex string
databasePath string
databaseName string
Expand Down
81 changes: 81 additions & 0 deletions cmd/transaction/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,3 +462,84 @@ func GeneratedMultiSignatureTransaction(
tx.TransactionBodyLength = uint32(len(tx.TransactionBodyBytes))
return tx
}

func GenerateTxRegisterNodeHDwallet(
tx *model.Transaction,
recipientAccountAddress, nodeAddress string,
lockedBalance int64,
poownMessageBytes, signature, nodePubKey []byte,
) *model.Transaction {
txBody := &model.NodeRegistrationTransactionBody{
NodePublicKey: nodePubKey,
NodeAddress: &model.NodeAddress{
Address: nodeAddress,
},
LockedBalance: lockedBalance,
Poown: &model.ProofOfOwnership{
MessageBytes: poownMessageBytes,
Signature: signature,
},
}
txBodyBytes := (&transaction.NodeRegistration{
Body: txBody,
NodeRegistrationQuery: query.NewNodeRegistrationQuery(),
}).GetBodyBytes()

tx.TransactionType = util.ConvertBytesToUint32(txTypeMap["registerNode"])
tx.TransactionBody = &model.Transaction_NodeRegistrationTransactionBody{
NodeRegistrationTransactionBody: txBody,
}
tx.TransactionBodyBytes = txBodyBytes
tx.TransactionBodyLength = uint32(len(txBodyBytes))

return tx
}

func GenerateTxUpdateNodeHDwallet(
tx *model.Transaction,
nodeAddress string,
lockedBalance int64,
poowMessageBytes, signature, nodePubKey []byte,
) *model.Transaction {
txBody := &model.UpdateNodeRegistrationTransactionBody{
NodePublicKey: nodePubKey,
NodeAddress: &model.NodeAddress{
Address: nodeAddress,
},
LockedBalance: lockedBalance,
Poown: &model.ProofOfOwnership{
MessageBytes: poowMessageBytes,
Signature: signature,
},
}
txBodyBytes := (&transaction.UpdateNodeRegistration{
Body: txBody,
NodeRegistrationQuery: query.NewNodeRegistrationQuery(),
}).GetBodyBytes()

tx.TransactionBodyLength = uint32(len(txBodyBytes))
tx.TransactionType = util.ConvertBytesToUint32(txTypeMap["updateNodeRegistration"])
tx.TransactionBody = &model.Transaction_UpdateNodeRegistrationTransactionBody{
UpdateNodeRegistrationTransactionBody: txBody,
}
tx.TransactionBodyBytes = txBodyBytes
return tx
}

func GenerateTxRemoveNodeHDwallet(tx *model.Transaction, nodePubKey []byte) *model.Transaction {
txBody := &model.RemoveNodeRegistrationTransactionBody{
NodePublicKey: nodePubKey,
}
txBodyBytes := (&transaction.RemoveNodeRegistration{
Body: txBody,
NodeRegistrationQuery: query.NewNodeRegistrationQuery(),
}).GetBodyBytes()

tx.TransactionType = util.ConvertBytesToUint32(txTypeMap["removeNodeRegistration"])
tx.TransactionBody = &model.Transaction_RemoveNodeRegistrationTransactionBody{
RemoveNodeRegistrationTransactionBody: txBody,
}
tx.TransactionBodyBytes = txBodyBytes
tx.TransactionBodyLength = uint32(len(txBodyBytes))
return tx
}