@@ -743,7 +743,7 @@ func (node *Node) processDeposit(ctx context.Context, out *mtg.Action, restored
743743 logger .Printf ("solana.ExtractTransferFromTransactionByIndex(%s %s %d) => %v" , out .OutputId , out .DepositHash .String , out .DepositIndex .Int64 , t )
744744 }
745745 if t == nil || t .AssetId != out .AssetId || t .Receiver != node .SolanaDepositEntry ().String () {
746- return node .failDepositRequest (ctx , out , "" )
746+ return node .failDepositRequest (ctx , out , "" , false )
747747 }
748748 asset , err := common .SafeReadAssetUntilSufficient (ctx , t .AssetId )
749749 if err != nil {
@@ -758,7 +758,7 @@ func (node *Node) processDeposit(ctx context.Context, out *mtg.Action, restored
758758 actual := mc .NewIntegerFromString (out .Amount .String ())
759759 if expected .Cmp (actual ) != 0 {
760760 logger .Printf ("invalid deposit amount: %s %s" , actual .String (), out .Amount .String ())
761- return node .failDepositRequest (ctx , out , "" )
761+ return node .failDepositRequest (ctx , out , "" , false )
762762 }
763763
764764 // user == nil: transfer solana withdrawn assets from mtg to mtg deposit entry by post call for failed prepare call
@@ -773,15 +773,15 @@ func (node *Node) processDeposit(ctx context.Context, out *mtg.Action, restored
773773 memo := solanaApp .ExtractMemoFromTransaction (ctx , tx , meta , node .SolanaPayer ())
774774 logger .Printf ("solana.ExtractMemoFromTransaction(%s) => %s" , tx .Signatures [0 ].String (), memo )
775775 if memo == "" {
776- return node .failDepositRequest (ctx , out , "" )
776+ return node .failDepositRequest (ctx , out , "" , false )
777777 }
778778 call , err = node .store .ReadSystemCallByRequestId (ctx , memo , common .RequestStateFailed )
779779 logger .Printf ("store.ReadSystemCallByRequestId(%s) => %v %v" , memo , call , err )
780780 if err != nil {
781781 panic (err )
782782 }
783783 if call == nil || call .Type != store .CallTypePrepare {
784- return node .failDepositRequest (ctx , out , "" )
784+ return node .failDepositRequest (ctx , out , "" , false )
785785 }
786786 superior , err := node .store .ReadSystemCallByRequestId (ctx , call .Superior , common .RequestStateFailed )
787787 logger .Printf ("store.ReadSystemCallByRequestId(%s) => %v %v" , call .Superior , superior , err )
@@ -800,7 +800,7 @@ func (node *Node) processDeposit(ctx context.Context, out *mtg.Action, restored
800800 panic (err )
801801 }
802802 if call == nil || call .State != common .RequestStateDone {
803- return node .failDepositRequest (ctx , out , "" )
803+ return node .failDepositRequest (ctx , out , "" , true )
804804 }
805805 switch call .Type {
806806 case store .CallTypeDeposit :
@@ -811,7 +811,7 @@ func (node *Node) processDeposit(ctx context.Context, out *mtg.Action, restored
811811 }
812812 call = superior
813813 default :
814- return node .failDepositRequest (ctx , out , "" )
814+ return node .failDepositRequest (ctx , out , "" , false )
815815 }
816816 }
817817 mix , err := bot .NewMixAddressFromString (user .MixAddress )
@@ -822,7 +822,7 @@ func (node *Node) processDeposit(ctx context.Context, out *mtg.Action, restored
822822 id = common .UniqueId (id , t .Receiver )
823823 mtx := node .buildTransaction (ctx , out , node .conf .AppId , t .AssetId , mix .Members (), int (mix .Threshold ), out .Amount .String (), []byte (out .DepositHash .String ), id )
824824 if mtx == nil {
825- return node .failDepositRequest (ctx , out , t .AssetId )
825+ return node .failDepositRequest (ctx , out , t .AssetId , false )
826826 }
827827 txs := []* mtg.Transaction {mtx }
828828 old := call .GetRefundIds ()
@@ -838,9 +838,9 @@ func (node *Node) processDeposit(ctx context.Context, out *mtg.Action, restored
838838 return txs , ""
839839}
840840
841- func (node * Node ) failDepositRequest (ctx context.Context , out * mtg.Action , compaction string ) ([]* mtg.Transaction , string ) {
841+ func (node * Node ) failDepositRequest (ctx context.Context , out * mtg.Action , compaction string , save bool ) ([]* mtg.Transaction , string ) {
842842 logger .Printf ("node.failDepositRequest(%v %s)" , out , compaction )
843- err := node .store .FailDepositRequestIfNotExist (ctx , out , compaction )
843+ err := node .store .FailDepositRequestIfNotExist (ctx , out , compaction , save )
844844 if err != nil {
845845 panic (err )
846846 }
@@ -1070,11 +1070,28 @@ func (node *Node) confirmBurnRelatedSystemCall(ctx context.Context, req *store.R
10701070 txs = append (txs , tx )
10711071 ids = append (ids , tx .TraceId )
10721072 }
1073+
1074+ fd , err := node .store .ReadFailedDepositByHash (ctx , signature )
1075+ if err != nil {
1076+ panic (err )
1077+ }
1078+ if fd != nil {
1079+ id := common .UniqueId (fd .Hash , fmt .Sprint (fd .Index ))
1080+ id = common .UniqueId (id , node .SolanaDepositEntry ().String ())
1081+ memo := []byte (fd .Hash )
1082+ tx := node .buildTransaction (ctx , req .Output , node .conf .AppId , fd .AssetId , mix .Members (), int (mix .Threshold ), fd .Amount , memo , id )
1083+ if tx == nil {
1084+ return node .failRequest (ctx , req , fd .AssetId )
1085+ }
1086+ txs = append (txs , tx )
1087+ ids = append (ids , tx .TraceId )
1088+ }
1089+
10731090 old := call .GetRefundIds ()
10741091 old = append (old , ids ... )
10751092 call .RefundTraces = sql.NullString {Valid : true , String : strings .Join (old , "," )}
10761093
1077- err = node .store .ConfirmBurnRelatedSystemCallWithRequest (ctx , req , call , txs )
1094+ err = node .store .ConfirmBurnRelatedSystemCallWithRequest (ctx , req , call , fd , txs )
10781095 if err != nil {
10791096 panic (err )
10801097 }
0 commit comments