Commit MetaInfo

Revisione33079fa2ab514f3eec82a88b183405dab0c2860 (tree)
Zeit2019-10-09 10:54:23
AutorChengcheng Zhang <943420582@qq.c...>
CommiterChengcheng Zhang

Log Message

refine callhtlc

Ändern Zusammenfassung

Diff

--- a/cmd/swap/commands.go
+++ b/cmd/swap/commands.go
@@ -463,31 +463,28 @@ var submitPaymentCmd = &cobra.Command{
463463
464464 switch action {
465465 case "deployhtlc":
466- spendParametersNum := len(args) - 3
467- for i := 0; i < spendParametersNum; i++ {
468- wa = append(wa, args[3+i])
466+ for i := 3; i < len(args); i++ {
467+ wa = append(wa, args[i])
469468 was = append(was, wa)
470469 wa = []string{}
471470 }
472- // case "callhtlc":
473- // if _, err := hex.DecodeString(preimage); err != nil || len(preimage) == 0 {
474- // fmt.Println("The part field of preimage is invalid:", preimage)
475- // os.Exit(0)
476- // }
471+ case "callhtlc":
472+ // callhtlc need 6 arguments at least
473+ if len(args) < 6 {
474+ fmt.Println("callhtlc need 3 arguments at least, len(args) is:", len(args))
475+ os.Exit(0)
476+ }
477477
478- // if _, err := hex.DecodeString(spendUTXOSig); err != nil || len(spendUTXOSig) != 128 {
479- // fmt.Println("The part field of spendUTXOSig is invalid:", spendUTXOSig)
480- // os.Exit(0)
481- // }
478+ wa = append(wa, args[3], args[4], "")
479+ was = append(was, wa)
480+ wa = []string{}
482481
483- // if _, err := hex.DecodeString(spendWalletSig); err != nil || len(spendWalletSig) != 128 {
484- // fmt.Println("The part field of spendWalletSig is invalid:", spendWalletSig)
485- // os.Exit(0)
486- // }
482+ for i := 5; i < len(args); i++ {
483+ wa = append(wa, args[i])
484+ was = append(was, wa)
485+ wa = []string{}
486+ }
487487
488- // spendUTXOSignatures = append(spendUTXOSignatures, preimage, spendUTXOSig, "")
489- // spendWalletSignatures = append(spendWalletSignatures, spendWalletSig)
490- // sigs = append(sigs, spendUTXOSignatures, spendWalletSignatures)
491488 // case "cancelhtlc":
492489 // if _, err := hex.DecodeString(spendUTXOSig); err != nil || len(spendUTXOSig) != 128 {
493490 // fmt.Println("The part field of spendUTXOSig is invalid:", spendUTXOSig)
@@ -549,8 +546,6 @@ var submitPaymentCmd = &cobra.Command{
549546 fmt.Println("action is invalid:", action)
550547 os.Exit(0)
551548 }
552- // spendWalletSignatures = append(spendWalletSignatures, spendWalletSig)
553- // sigs = append(sigs, spendUTXOSignatures, spendWalletSignatures)
554549
555550 server := &swap.Server{
556551 IP: ip,
--- a/swap/transaction.go
+++ b/swap/transaction.go
@@ -204,11 +204,11 @@ func BuildUnlockedTx(s *Server, guid, contractUTXOID, contractAsset, receiver st
204204 OutputID: contractUTXOID,
205205 }
206206
207- spendWalletInput := SpendWalletInput{
208- Type: "spend_wallet",
209- AssetID: contractAsset,
210- Amount: contractAmount,
211- }
207+ // spendWalletInput := SpendWalletInput{
208+ // Type: "spend_wallet",
209+ // AssetID: contractAsset,
210+ // Amount: contractAmount,
211+ // }
212212
213213 // outputs:
214214 controlAddressOutput := ControlAddressOutput{
@@ -219,7 +219,8 @@ func BuildUnlockedTx(s *Server, guid, contractUTXOID, contractAsset, receiver st
219219 }
220220
221221 var inputs, outputs []interface{}
222- inputs = append(inputs, spendUTXOInput, spendWalletInput)
222+ // inputs = append(inputs, spendUTXOInput, spendWalletInput)
223+ inputs = append(inputs, spendUTXOInput)
223224 outputs = append(outputs, controlAddressOutput)
224225 payload, err := json.Marshal(buildTxReq{
225226 GUID: guid,
Show on old repository browser