跳到主要内容

stellarSignTransaction

Stellar:签名交易

使用指定 BIP32 路径派生的私钥对交易进行签名。用户需要在 Ukey Wallet 上核对交易目标、金额、费用等关键信息后确认。

const result = await HardwareSDK.stellarSignTransaction(
connectId,
deviceId,
params,
);

参数

可选通用参数

  • path - 必需 string | Array<number>,该特殊链的路径长度固定为 3更多信息
  • networkPassphrase - 必需 string,网络密码短语。
  • transaction - 必需 ObjectStellarTransaction 类型。

StellarTransaction 类型

export type StellarTransaction = {
source: string;
fee: number;
sequence: string | number;
timebounds?: {
minTime: number;
maxTime: number;
};
memo?: {
type: 0 | 1 | 2 | 3 | 4;
id?: string;
text?: string;
hash?: string | Buffer;
};
operations: StellarOperation[];
};

示例

const response = await HardwareSDK.stellarSignTransaction(connectId, deviceId, {
path: "m/44'/148'/1'",
networkPassphrase: "Test SDF Network ; September 2015",
transaction: {
source: "GCFXKXQ6X7W7NVTQG6G7X5Q2LJ4J2Y6V5O2X6XWQG3B7M4O6Q1S2D3F4",
fee: 240,
sequence: 4238498308,
memo: {
type: 0,
},
operations: [
{
type: "payment",
source: "GCFXKXQ6X7W7NVTQG6G7X5Q2LJ4J2Y6V5O2X6XWQG3B7M4O6Q1S2D3F4",
destination: "GDUKMGUGDZQK6YH6Q4L2JQ7TQ5E7VQ3H4M8GQ2J5N6R1W3F9K2L4M6P7",
amount: "12000",
},
],
},
});

返回结果

{
success: true,
payload: {
public_key: string, // 返回的公钥
signature: string // 签名结果
}
}

错误

{
success: false,
payload: {
error: string, // 错误消息
code: number // 错误码
}
}