-
Notifications
You must be signed in to change notification settings - Fork 0
/
transaction.go
41 lines (36 loc) · 1.17 KB
/
transaction.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package operation
import (
"fmt"
"github.com/MixinNetwork/go-safe-sdk/bitcoin"
"github.com/MixinNetwork/go-safe-sdk/ethereum"
)
func SignSafeTx(rawStr, privateStr string, chain byte) (string, error) {
switch chain {
case SafeChainBitcoin, SafeChainLitecoin:
return bitcoin.SignTx(rawStr, privateStr, chain)
case SafeChainEthereum, SafeChainMVM, SafeChainPolygon:
return ethereum.SignTx(rawStr, privateStr)
default:
return "", fmt.Errorf("invalid chain: %d", chain)
}
}
func HashMessageForSignature(msg string, chain byte) ([]byte, error) {
switch chain {
case SafeChainBitcoin, SafeChainLitecoin:
return bitcoin.HashMessageForSignature(msg, chain)
case SafeChainEthereum, SafeChainMVM, SafeChainPolygon:
return ethereum.HashMessageForSignature(msg)
default:
return nil, fmt.Errorf("invalid chain: %d", chain)
}
}
func CheckTransactionPartiallySignedBy(raw, public string, chain byte) bool {
switch chain {
case SafeChainBitcoin, SafeChainLitecoin:
return bitcoin.CheckTransactionPartiallySignedBy(raw, public)
case SafeChainEthereum, SafeChainMVM, SafeChainPolygon:
return ethereum.CheckTransactionPartiallySignedBy(raw, public)
default:
return false
}
}