@@ -239,22 +239,28 @@ func GenerateBasicTransaction(
239
239
timestamp , fee int64 ,
240
240
recipientAccountAddress string ,
241
241
) * model.Transaction {
242
- var senderAccountAddress string
243
- switch model .SignatureType (senderSignatureType ) {
244
- case model .SignatureType_DefaultSignature :
245
- senderAccountAddress = crypto .NewEd25519Signature ().GetAddressFromSeed (senderSeed )
246
- case model .SignatureType_BitcoinSignature :
247
- var (
248
- bitcoinSig = crypto .NewBitcoinSignature (crypto .DefaultBitcoinNetworkParams (), crypto .DefaultBitcoinCurve ())
249
- pubKey = bitcoinSig .GetPublicKeyFromSeed (senderSeed , crypto .DefaultBitcoinPublicKeyFormat ())
250
- err error
251
- )
252
- senderAccountAddress , err = bitcoinSig .GetAddressPublicKey (pubKey )
253
- if err != nil {
254
- fmt .Println ("GenerateBasicTransaction-BitcoinSignature-Failed GetPublicKey" )
242
+ var (
243
+ senderAccountAddress string
244
+ )
245
+ if senderSeed == "" {
246
+ senderAccountAddress = senderAddress
247
+ } else {
248
+ switch model .SignatureType (senderSignatureType ) {
249
+ case model .SignatureType_DefaultSignature :
250
+ senderAccountAddress = crypto .NewEd25519Signature ().GetAddressFromSeed (senderSeed )
251
+ case model .SignatureType_BitcoinSignature :
252
+ var (
253
+ bitcoinSig = crypto .NewBitcoinSignature (crypto .DefaultBitcoinNetworkParams (), crypto .DefaultBitcoinCurve ())
254
+ pubKey = bitcoinSig .GetPublicKeyFromSeed (senderSeed , crypto .DefaultBitcoinPublicKeyFormat ())
255
+ err error
256
+ )
257
+ senderAccountAddress , err = bitcoinSig .GetAddressPublicKey (pubKey )
258
+ if err != nil {
259
+ fmt .Println ("GenerateBasicTransaction-BitcoinSignature-Failed GetPublicKey" )
260
+ }
261
+ default :
262
+ panic ("GenerateBasicTransaction-Invalid Signature Type" )
255
263
}
256
- default :
257
- panic ("GenerateBasicTransaction-Invalid Signature Type" )
258
264
}
259
265
260
266
if timestamp <= 0 {
@@ -318,6 +324,9 @@ func GenerateSignedTxBytes(tx *model.Transaction, senderSeed string, signatureTy
318
324
tx .Fee += minimumFee
319
325
320
326
unsignedTxBytes , _ := transactionUtil .GetTransactionBytes (tx , false )
327
+ if senderSeed == "" {
328
+ return unsignedTxBytes
329
+ }
321
330
tx .Signature , _ = signature .Sign (
322
331
unsignedTxBytes ,
323
332
model .SignatureType (signatureType ),
@@ -388,7 +397,7 @@ func GeneratedMultiSignatureTransaction(
388
397
minSignature uint32 ,
389
398
nonce int64 ,
390
399
unsignedTxHex , txHash string ,
391
- addressSignatures , addresses []string ,
400
+ addressSignatures map [ string ] string , addresses []string ,
392
401
) * model.Transaction {
393
402
var (
394
403
signatures = make (map [string ][]byte )
@@ -410,29 +419,28 @@ func GeneratedMultiSignatureTransaction(
410
419
return nil
411
420
}
412
421
}
413
-
414
422
if txHash != "" {
415
423
transactionHash , err := hex .DecodeString (txHash )
416
424
if err != nil {
417
425
return nil
418
426
}
419
- for _ , v := range addressSignatures {
420
- asig := strings .Split (v , "-" )
421
- if len (asig ) < 2 {
422
- return nil
427
+ for k , v := range addressSignatures {
428
+ if k == "" {
429
+ sigType := util .ConvertUint32ToBytes (2 )
430
+ signatures [k ] = sigType
431
+ } else {
432
+ signature , err := hex .DecodeString (v )
433
+ if err != nil {
434
+ return nil
435
+ }
436
+ signatures [k ] = signature
423
437
}
424
- signature , err := hex .DecodeString (asig [1 ])
425
- if err != nil {
426
- return nil
427
- }
428
- signatures [asig [0 ]] = signature
429
438
}
430
439
signatureInfo = & model.SignatureInfo {
431
440
TransactionHash : transactionHash ,
432
441
Signatures : signatures ,
433
442
}
434
443
}
435
-
436
444
tx .TransactionType = util .ConvertBytesToUint32 (txTypeMap ["multiSignature" ])
437
445
txBody := & model.MultiSignatureTransactionBody {
438
446
MultiSignatureInfo : multiSigInfo ,
0 commit comments