Bytom项目:
Github:https://github.com/Bytom/bytom
这部分适用于以Bytom自己的帐户模式发送交易的用户。
API接口构建事务,代码api/transact.go#L120
以标准非BTM资产的交易为例,ID由F组成的BTM资产在此交易中仅作为气体。此交易意味着将99个指定资产花费到指定地址,其输入请求的已构建交易的json为如下:
{
"base_transaction": null,
"actions": [
{
"account_id": "0ER7MEFGG0A02",
"amount": 20000000,
"asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"type": "spend_account"
},
{
"account_id": "0ER7MEFGG0A02",
"amount": 99,
"asset_id": "42275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f",
"type": "spend_account"
},
{
"amount": 99,
"asset_id": "42275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f",
"address": "sm1qxe4jwhkekgnxkezu7xutu5gqnnpmyc8ppq98me",
"type": "control_address"
}
],
"ttl": 0,
"time_range": 0
}
相应的响应对象的源代码如下:
// BuildRequest is main struct when building transactions
type BuildRequest struct {
Tx *types.TxData `json:"base_transaction"`
Actions []map[string]interface{} `json:"actions"`
TTL json.Duration `json:"ttl"`
TimeRange uint64 `json:"time_range"`
}
结构字段:
-Tx
TxData
个交易,保留字段,为空
-TTL
个已构建事务的生存期(ms),这意味着已缓存的utxo不能在该时间段内用于另一个构建事务,除非剩下的utxo足以建立一个新事务,否则会提示错误。 ttl
为0,默认值为600s(5分钟)
-TimeRange
时间戳表示该事务将不在此blockheight(时间戳)之后上链。为避免由于传输延迟而在转移事务时等待太长时间,如果未将其打包在指定的TimeRange中,则该事务将过期。
-Actions
actions
交易结构,所有交易均由动作组成,map
的类型interface{}
确保动作类型的可扩展性。动作必须包含类型字段以区分action
主要包含input
和output
之间,其详细介绍:
-input action
类型:
-发行发行资产
-在帐户模式下,exped_account花费utxo
-支出_支出_未支出_支出直接花费指定的utxo
-output action
类型:
-以地址模式接收control_address
-控制程序以(程序)合同方式接收
-退休退休资产
注意: -一个事务必须包含一个输入和一个输出或t在构建输入和输出时,输入a的资产总和必须等于输出,否则事务将显示错误消息,即输入和输出的不平衡。 -气体:所有投入的BTM资产减少为所有产出的资产 -交易中的资产金额全部以neu为单位,1 BTM = 1000 mBTM = 100,000,000neu
action
类型:
issueAction
结构源代码:
type issueAction struct {
assets *Registry
bc.AssetAmount
}
type AssetAmount struct {
AssetId *AssetID `protobuf:"bytes,1,opt,name=asset_id,json=assetId" json:"asset_id,omitempty"`
Amount uint64 `protobuf:"varint,2,opt,name=amount" json:"amount,omitempty"`
}
建设领域:
-assets
资产管理,用户无需设置参数
-AssetAmount
ssetID和相应的资产金额,需要通过AssetID
创建create-asset
,不能使用BTM
的资产ID
json
的{{1}}格式:
issueAction
发行资产示例:
(问题{
"amount": 100000000,
"asset_id": "3152a15da72be51b330e1c0f8e1c0db669269809da4f16443ff266e07cc43680",
"type": "issue"
}
是900000000
到assetID
的{{1}},天然气是42275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f
对BTM资产的影响)
sm1qxe4jwhkekgnxkezu7xutu5gqnnpmyc8ppq98me
支出帐户
20000000
结构源代码:
{
"base_transaction": null,
"actions": [
{
"account_id": "0ER7MEFGG0A02",
"amount": 20000000,
"asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"type": "spend_account"
},
{
"amount": 900000000,
"asset_id": "42275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f",
"type": "issue"
},
{
"amount": 900000000,
"asset_id": "42275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f",
"address": "sm1qxe4jwhkekgnxkezu7xutu5gqnnpmyc8ppq98me",
"type": "control_address"
}
],
"ttl": 0,
"time_range": 0
}
结构字段:
-spendAction
帐户管理。用户无需设置参数
-type spendAction struct {
accounts *Manager
bc.AssetAmount
AccountID string `json:"account_id"`
ClientToken *string `json:"client_token"`
}
type AssetAmount struct {
AssetId *AssetID `protobuf:"bytes,1,opt,name=asset_id,json=assetId" json:"asset_id,omitempty"`
Amount uint64 `protobuf:"varint,2,opt,name=amount" json:"amount,omitempty"`
}
支出帐户
-accounts
AssetID和相应的资产金额
-AccountID
用户的UTXO保留限制,为空
AssetAmount
的{{1}}格式:
ClientToken
交易示例如下:
(将spendAction``json
neu Bytom资产转移到spendAction
,天然气为{
"account_id": "0BF63M2U00A04",
"amount": 2000000000,
"asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"type": "spend_account"
}
neu =输入BTM资产-输出BTM资产)
100000000
支出_未使用支出_输出
sm1qxe4jwhkekgnxkezu7xutu5gqnnpmyc8ppq98me
结构源代码:
20000000
结构字段:
-{
"base_transaction": null,
"actions": [
{
"account_id": "0ER7MEFGG0A02",
"amount": 120000000,
"asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"type": "spend_account"
},
{
"amount": 100000000,
"asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"address": "sm1qxe4jwhkekgnxkezu7xutu5gqnnpmyc8ppq98me",
"type": "control_address"
}
],
"ttl": 0,
"time_range": 0
}
帐户管理。用户无需设置参数
-spendUTXOAction
UTXO的ID,通过type spendUTXOAction struct {
accounts *Manager
OutputID *bc.Hash `json:"output_id"`
ClientToken *string `json:"client_token"`
}
,accounts
对应于API返回结果的字段OutputID
查询可用的UTXO
-list-unspent-outputs
保留的UTXO限制,为空
OutputID
的{{1}}格式:
id
expenseUTXO的交易示例:
(通过UTXO将ClientToken
neu BTM资产转移到json
,gas = BTM资产的输入UTXO-输出BTM资产)
spendUTXOAction
控制地址
{
"type": "spend_account_unspent_output",
"output_id": "58f29f0f85f7bd2a91088bcbe536dee41cd0642dfb1480d3a88589bdbfd642d9"
}
结构源代码:
100000000
结构领域:
-sm1qxe4jwhkekgnxkezu7xutu5gqnnpmyc8ppq98me
接收地址,可以通过{
"base_transaction": null,
"actions": [
{
"output_id": "58f29f0f85f7bd2a91088bcbe536dee41cd0642dfb1480d3a88589bdbfd642d9",
"type": "spend_account_unspent_output"
},
{
"amount": 100000000,
"asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"address": "sm1qxe4jwhkekgnxkezu7xutu5gqnnpmyc8ppq98me",
"type": "control_address"
}
],
"ttl": 0,
"time_range": 0
}
API接口创建地址
-controlAddressAction
要接收的资产ID和相应的资产金额
type controlAddressAction struct {
bc.AssetAmount
Address string `json:"address"`
}
type AssetAmount struct {
AssetId *AssetID `protobuf:"bytes,1,opt,name=asset_id,json=assetId" json:"asset_id,omitempty"`
Amount uint64 `protobuf:"varint,2,opt,name=amount" json:"amount,omitempty"`
}
的{{1}}格式:
Address
交易示例:
(以帐户模式将create-account-receiver
neuBTM地址转移到AssetAmount
,json
键入用于接收的使用地址)
controlAddressAction
control_program
{
"amount": 100000000,
"asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"address": "bm1q50u3z8empm5ke0g3ngl2t3sqtr6sd7cepd3z68",
"type": "control_address"
}
结构源代码:
100000000
结构领域:
-sm1qxe4jwhkekgnxkezu7xutu5gqnnpmyc8ppq98me
合同脚本通过control_address
API接口构建和接收{
"base_transaction": null,
"actions": [
{
"account_id": "0ER7MEFGG0A02",
"amount": 120000000,
"asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"type": "spend_account"
},
{
"amount": 100000000,
"asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"address": "sm1qxe4jwhkekgnxkezu7xutu5gqnnpmyc8ppq98me",
"type": "control_address"
}
],
"ttl": 0,
"time_range": 0
}
来接收资产(controlProgramAction
和type controlProgramAction struct {
bc.AssetAmount
Program json.HexBytes `json:"control_program"`
}
type AssetAmount struct {
AssetId *AssetID `protobuf:"bytes,1,opt,name=asset_id,json=assetId" json:"asset_id,omitempty"`
Amount uint64 `protobuf:"varint,2,opt,name=amount" json:"amount,omitempty"`
}
的返回结果是一对一的对应关系)
-Program
要接收的AssetID和相应的资产金额
create-account-receiver
的{{1}}格式:
program
交易示例:
(将program
neu BTM资产转移到address
(与AssetAmount
一一对应,json
,controlProgramAction
类型使用{
"amount": 100000000,
"asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"control_program":"0014a3f9111f3b0ee96cbd119a3ea5c60058f506fb19",
"type": "control_program"
}
来接收)< / p>
100000000
退休
program
结构性源代码如下:
address
结构领域:
-0014a3f9111f3b0ee96cbd119a3ea5c60058f506fb19
要接收的资产ID和相应的资产金额
control_program
的{{1}}格式:
program
交易示例:
(以帐户模式转移{
"base_transaction": null,
"actions": [
{
"account_id": "0ER7MEFGG0A02",
"amount": 120000000,
"asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"type": "spend_account"
},
{
"amount": 100000000,
"asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"control_program": "0014a3f9111f3b0ee96cbd119a3ea5c60058f506fb19",
"type": "control_program"
}
],
"ttl": 0,
"time_range": 0
}
neu BTM退休资产,retireAction
退回指定数量的资产)
type retireAction struct {
bc.AssetAmount
}
type AssetAmount struct {
AssetId *AssetID `protobuf:"bytes,1,opt,name=asset_id,json=assetId" json:"asset_id,omitempty"`
Amount uint64 `protobuf:"varint,2,opt,name=amount" json:"amount,omitempty"`
}
实现AssetAmount
的输入构造,构造事务实现后,可以通过http调用发送事务,json结果为:
json
相应的响应对象的源代码如下:
retireAction
结构字段:
-{
"amount": 900000000,
"asset_id": "3152a15da72be51b330e1c0f8e1c0db669269809da4f16443ff266e07cc43680",
"type": "retire"
}
关于交易信息,包括100000000
和retire
:
-{
"base_transaction": null,
"actions": [
{
"account_id": "0ER7MEFGG0A02",
"amount": 120000000,
"asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"type": "spend_account"
},
{
"amount": 100000000,
"asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"type": "retire"
}
],
"ttl": 0,
"time_range": 0
}
表示向用户显示的交易数据部分,该部分对用户可见
-build-transaction
个交易版本
-{
"allow_additional_actions": false,
"raw_transaction": "070100020161015f1190c60818b4aff485c865113c802942f29ce09088cae1b117fc4c8db2292212ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8099c4d599010001160014a86c83ee12e6d790fb388345cc2e2b87056a077301000161015fb018097c4040c8dd86d95611a13c24f90d4c9d9d06b25f5c9ed0556ac8abd73442275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f80a094a58d1d0101160014068840e56af74038571f223b1c99f1b60caaf456010003013effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80bfffcb9901011600140b946646626c55a52a325c8bb48de792284d9b7200013e42275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f9d9f94a58d1d01160014c8b4391bab4923a83b955170d24ee4ca5b6ec3fb00013942275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f6301160014366b275ed9b2266b645cf1b8be51009cc3b260e100",
"signing_instructions": [
{
"position": 0,
"witness_components": [
{
"keys": [
{
"derivation_path": [
"010100000000000000",
"0100000000000000"
],
"xpub": "de0db655c091b2838ccb6cddb675779b0a9a4204b122e61699b339867dd10eb0dbdc926882ff6dd75c099c181c60d63eab0033a4b0a4d0a8c78079e39d7ad1d8"
}
],
"quorum": 1,
"signatures": null,
"type": "raw_tx_signature"
},
{
"type": "data",
"value": "d174db6506e35f2decb5be148c2984bfd0f6c67f043365bf642d1af387c04fd5"
}
]
},
{
"position": 1,
"witness_components": [
{
"keys": [
{
"derivation_path": [
"010100000000000000",
"0800000000000000"
],
"xpub": "de0db655c091b2838ccb6cddb675779b0a9a4204b122e61699b339867dd10eb0dbdc926882ff6dd75c099c181c60d63eab0033a4b0a4d0a8c78079e39d7ad1d8"
}
],
"quorum": 1,
"signatures": null,
"type": "raw_tx_signature"
},
{
"type": "data",
"value": "05cdbcc705f07ad87521835bbba226ad7b430cc24e5e3f008edbe61540535419"
}
]
}
]
}
事务序列化后的大小
-// Template represents a partially- or fully-signed transaction.
type Template struct {
Transaction *types.Tx `json:"raw_transaction"`
SigningInstructions []*SigningInstruction `json:"signing_instructions"`
// AllowAdditional affects whether Sign commits to the tx sighash or
// to individual details of the tx so far. When true, signatures
// commit to tx details, and new details may be added but existing
// ones cannot be changed. When false, signatures commit to the tx
// as a whole, and any change to the tx invalidates the signature.
AllowAdditional bool `json:"allow_additional_actions"`
}
在链上提交交易的最大时间戳(blockheight)(如果区块高度达到blockheight时,如果交易尚未在链上,则该交易将成为帝国)
-Transaction
个交易输入
-TxData
个交易输出
-bc.Tx
表示用于处理系统中交易的转换结构。这部分对用户不可见,因此不再详细描述
-TxData
交易的签名信息
-Version
至SerializedSize
签名位置
-建筑交易中TimeRange
至Inputs
签名Outputs
的数据信息为bc.Tx
,无签名;如果交易成功签名,则该字段将存在签名信息。该字段是一个接口,主要包括三种不同类型:
-SigningInstructions
将Position
的合约程序哈希到交易input action
中,然后签署哈希值
-WitnessComponents
交易签名(数组类型),执行input action
后,会有一个值
-signatures
(数组类型)包括主公钥null
和派生路径SignatureWitness
,它们可以在签名期间找到对应的派生私钥input action
,然后使用派生密钥进行签名
-Template
个signatures
帐户的数量,长度必须等于上面的sign-transaction
。如果keys
等于1,则它是单个签名帐户,或者是多个签名帐户
-xpub
签名数据,derivation_path
的哈希值作为签名数据。如果child_xprv
为空,则根据当前交易ID和对应的操作位置生成哈希。 InputID,然后将它们用作命令数据以自动构建key
-quorum
的{{1}}哈希InoutID(此字段在bc.Tx中),事务ID为keys
-quorum
交易签名(数组类型),执行program
后,会有一个值
-program
(数组类型)包括program
和派生路径program
,您可以在其签名期RawTxSigWitness
中找到派生私钥,然后使用派生私钥进行签名
-input action
个Template
帐户的数量,长度必须等于以上signatures
。如果sign-transaction
等于1,则表示单个签名帐户,或者它的多个签名帐户。签名帐户
-keys
这种类型不需要签名,请验证合同程序的其他数据
-xpub
是否允许交易其他数据,如果对于derivation_path
,则将向交易添加其他数据,但不会影响交易执行child_xprv
脚本,不会影响交易的执行。签名结果;如果对于key
,整个交易作为一个整体进行签名,那么任何数据更改都会影响交易的签名
估算费用界面quorum
用于keys
费用估算,估算结果必须添加到quorum
结果中,然后签名并提交交易。主要过程如下:
DataWitness
预算程序费的输入请求json格式如下:
AllowAdditional
相应的响应对象的源代码如下:
true
您可以在build-transaction的结果描述中看到包括program
在内的相关字段
成功返回json结果后,调用false
接口如下:
estimate ws-transaction - gas
相应的响应对象的源代码如下:
build -transaction
结构字段解释如下:
-build -transaction
估算气体(neu),您可以通过输入操作将值添加到build-transaction的BTM资产中
-
build - estimate - build - sign - submit
用于存储交易的气体
{
"transaction_template": {
"allow_additional_actions": false,
"raw_transaction": "070100020161015f1190c60818b4aff485c865113c802942f29ce09088cae1b117fc4c8db2292212ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8099c4d599010001160014a86c83ee12e6d790fb388345cc2e2b87056a077301000161015fb018097c4040c8dd86d95611a13c24f90d4c9d9d06b25f5c9ed0556ac8abd73442275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f80a094a58d1d0101160014068840e56af74038571f223b1c99f1b60caaf456010003013effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80bfffcb9901011600140b946646626c55a52a325c8bb48de792284d9b7200013e42275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f9d9f94a58d1d01160014c8b4391bab4923a83b955170d24ee4ca5b6ec3fb00013942275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f6301160014366b275ed9b2266b645cf1b8be51009cc3b260e100",
"signing_instructions": [
{
"position": 0,
"witness_components": [
{
"keys": [
{
"derivation_path": [
"010100000000000000",
"0100000000000000"
],
"xpub": "de0db655c091b2838ccb6cddb675779b0a9a4204b122e61699b339867dd10eb0dbdc926882ff6dd75c099c181c60d63eab0033a4b0a4d0a8c78079e39d7ad1d8"
}
],
"quorum": 1,
"signatures": null,
"type": "raw_tx_signature"
},
{
"type": "data",
"value": "d174db6506e35f2decb5be148c2984bfd0f6c67f043365bf642d1af387c04fd5"
}
]
},
{
"position": 1,
"witness_components": [
{
"keys": [
{
"derivation_path": [
"010100000000000000",
"0800000000000000"
],
"xpub": "de0db655c091b2838ccb6cddb675779b0a9a4204b122e61699b339867dd10eb0dbdc926882ff6dd75c099c181c60d63eab0033a4b0a4d0a8c78079e39d7ad1d8"
}
],
"quorum": 1,
"signatures": null,
"type": "raw_tx_signature"
},
{
"type": "data",
"value": "05cdbcc705f07ad87521835bbba226ad7b430cc24e5e3f008edbe61540535419"
}
]
}
]
}
}
用于BVM的气体答案 0 :(得分:0)
APIinterface签名交易,代码api/hsm.go#L53
签收交易的输入请求为json格式,如下:
{
"password": "123456",
"transaction": {
"allow_additional_actions": false,
"raw_transaction": "070100020161015f1190c60818b4aff485c865113c802942f29ce09088cae1b117fc4c8db2292212ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8099c4d599010001160014a86c83ee12e6d790fb388345cc2e2b87056a077301000161015fb018097c4040c8dd86d95611a13c24f90d4c9d9d06b25f5c9ed0556ac8abd73442275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f80a094a58d1d0101160014068840e56af74038571f223b1c99f1b60caaf456010003013effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80bfffcb9901011600140b946646626c55a52a325c8bb48de792284d9b7200013e42275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f9d9f94a58d1d01160014c8b4391bab4923a83b955170d24ee4ca5b6ec3fb00013942275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f6301160014366b275ed9b2266b645cf1b8be51009cc3b260e100",
"signing_instructions": [
{
"position": 0,
"witness_components": [
{
"keys": [
{
"derivation_path": [
"010100000000000000",
"0100000000000000"
],
"xpub": "de0db655c091b2838ccb6cddb675779b0a9a4204b122e61699b339867dd10eb0dbdc926882ff6dd75c099c181c60d63eab0033a4b0a4d0a8c78079e39d7ad1d8"
}
],
"quorum": 1,
"signatures": null,
"type": "raw_tx_signature"
},
{
"type": "data",
"value": "d174db6506e35f2decb5be148c2984bfd0f6c67f043365bf642d1af387c04fd5"
}
]
},
{
"position": 1,
"witness_components": [
{
"keys": [
{
"derivation_path": [
"010100000000000000",
"0800000000000000"
],
"xpub": "de0db655c091b2838ccb6cddb675779b0a9a4204b122e61699b339867dd10eb0dbdc926882ff6dd75c099c181c60d63eab0033a4b0a4d0a8c78079e39d7ad1d8"
}
],
"quorum": 1,
"signatures": null,
"type": "raw_tx_signature"
},
{
"type": "data",
"value": "05cdbcc705f07ad87521835bbba226ad7b430cc24e5e3f008edbe61540535419"
}
]
}
]
}
}
相应请求对象的源代码如下::
type SignRequest struct { //function pseudohsmSignTemplates request
Password string `json:"password"`
Txs txbuilder.Template `json:"transaction"`
}
结构字段解释如下:
-Password
签名密码,根据密码分析节点服务器上用户的私钥,然后使用私钥签名进行交易
-Txs
交易模板,构建交易的返回结果,其结构类型为txbuilder.Template
,您可以在构建交易的说明中看到相关字段
sign-transaction
成功请求后返回的json结果如下:
{
"sign_complete": true,
"transaction": {
"allow_additional_actions": false,
"raw_transaction": "070100020161015f1190c60818b4aff485c865113c802942f29ce09088cae1b117fc4c8db2292212ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8099c4d599010001160014a86c83ee12e6d790fb388345cc2e2b87056a0773630240273d5fc4fb06909fbc2968ea91c411fd20f690c88e74284ce2732052400129948538562fe432afd6cf17e590e8645b80edf80b9d9581d0a980d5f9f859e3880620d174db6506e35f2decb5be148c2984bfd0f6c67f043365bf642d1af387c04fd50161015fb018097c4040c8dd86d95611a13c24f90d4c9d9d06b25f5c9ed0556ac8abd73442275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f80a094a58d1d0101160014068840e56af74038571f223b1c99f1b60caaf4566302400cf0beefceaf9fbf1efadedeff7aee5b38ee7a25a20d78b630b01613bc2f8c9230555a6e09aaa11a82ba68c0fc9e98a47c852dfe3de851d93f9b2b7ce256f90d2005cdbcc705f07ad87521835bbba226ad7b430cc24e5e3f008edbe6154053541903013effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80bfffcb9901011600140b946646626c55a52a325c8bb48de792284d9b7200013e42275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f9d9f94a58d1d01160014c8b4391bab4923a83b955170d24ee4ca5b6ec3fb00013942275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f6301160014366b275ed9b2266b645cf1b8be51009cc3b260e100",
"signing_instructions": [
{
"position": 0,
"witness_components": [
{
"keys": [
{
"derivation_path": [
"010100000000000000",
"0100000000000000"
],
"xpub": "de0db655c091b2838ccb6cddb675779b0a9a4204b122e61699b339867dd10eb0dbdc926882ff6dd75c099c181c60d63eab0033a4b0a4d0a8c78079e39d7ad1d8"
}
],
"quorum": 1,
"signatures": [
"273d5fc4fb06909fbc2968ea91c411fd20f690c88e74284ce2732052400129948538562fe432afd6cf17e590e8645b80edf80b9d9581d0a980d5f9f859e38806"
],
"type": "raw_tx_signature"
},
{
"type": "data",
"value": "d174db6506e35f2decb5be148c2984bfd0f6c67f043365bf642d1af387c04fd5"
}
]
},
{
"position": 1,
"witness_components": [
{
"keys": [
{
"derivation_path": [
"010100000000000000",
"0800000000000000"
],
"xpub": "de0db655c091b2838ccb6cddb675779b0a9a4204b122e61699b339867dd10eb0dbdc926882ff6dd75c099c181c60d63eab0033a4b0a4d0a8c78079e39d7ad1d8"
}
],
"quorum": 1,
"signatures": [
"0cf0beefceaf9fbf1efadedeff7aee5b38ee7a25a20d78b630b01613bc2f8c9230555a6e09aaa11a82ba68c0fc9e98a47c852dfe3de851d93f9b2b7ce256f90d"
],
"type": "raw_tx_signature"
},
{
"type": "data",
"value": "05cdbcc705f07ad87521835bbba226ad7b430cc24e5e3f008edbe61540535419"
}
]
}
]
}
}
相应的响应对象的源代码如下:
type signResp struct {
Tx *txbuilder.Template `json:"transaction"`
SignComplete bool `json:"sign_complete"`
}
结构字段说明如下:
-txbuilder. Template
签名后的交易模板Tx
,如果签名成功的signatures
从null更改为签名的值,并且raw_transaction
的长度会更长,因为{{1 }}部分添加以验证签名信息的参数
去完成 -
-BC. Tx
标记签名是否完成,对于SignComplete
,签名完成,还是对于true
,签名,对于单个签名,通常是错误的签名密码,而对于其他签名则需要其他签名-签名。如果签名失败,请使用正确的密码再次签名,无需再次false
APIinterface提交事务,代码api/transact.go#L135
提交交易的输入请求采用json格式,如下所示:
build-transaction
源代码的请求对象如下所示:
{
"raw_transaction": "070100020161015f1190c60818b4aff485c865113c802942f29ce09088cae1b117fc4c8db2292212ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8099c4d599010001160014a86c83ee12e6d790fb388345cc2e2b87056a0773630240273d5fc4fb06909fbc2968ea91c411fd20f690c88e74284ce2732052400129948538562fe432afd6cf17e590e8645b80edf80b9d9581d0a980d5f9f859e3880620d174db6506e35f2decb5be148c2984bfd0f6c67f043365bf642d1af387c04fd50161015fb018097c4040c8dd86d95611a13c24f90d4c9d9d06b25f5c9ed0556ac8abd73442275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f80a094a58d1d0101160014068840e56af74038571f223b1c99f1b60caaf4566302400cf0beefceaf9fbf1efadedeff7aee5b38ee7a25a20d78b630b01613bc2f8c9230555a6e09aaa11a82ba68c0fc9e98a47c852dfe3de851d93f9b2b7ce256f90d2005cdbcc705f07ad87521835bbba226ad7b430cc24e5e3f008edbe6154053541903013effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80bfffcb9901011600140b946646626c55a52a325c8bb48de792284d9b7200013e42275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f9d9f94a58d1d01160014c8b4391bab4923a83b955170d24ee4ca5b6ec3fb00013942275aacbeda1522cd41580f875c3c452daf5174b17ba062bf0ab71a568c123f6301160014366b275ed9b2266b645cf1b8be51009cc3b260e100"
}
结构字段说明如下:
-签名后的type SubmitRequest struct { //function submit request
Tx types.Tx `json:"raw_transaction"`
}
交易信息。Tx
不是raw_transaction
的预定结果,而是签名sign-transaction
的{{1}}字段交易的结果
raw_transaction
成功请求后返回的json结果如下:
transaction
与源代码相对应的响应对象如下:
submit-transaction
结构字段说明如下:
-{
"tx_id": "2c0624a7d251c29d4d1ad14297c69919214e78d995affd57e73fbf84ece361cd"
}
交易ID,当交易提交到交易池时显示交易信息,否则表明交易失败